<?php
declare (strict_types=1);

namespace app\content\logic\content;

use app\common\exception\LogicException;
use app\common\logic\navi\NaviBottom;
use ArrayObject;

/**
 * 单页逻辑层
 */
class Single
{
    /**
     * 页面
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-06-11
     */
    public function fetch($type, $id)
    {
        // 参数
        if (!$type || !$id) {
            throw new LogicException("参数错误");
        }
        $data = new ArrayObject();

        // 查询
        switch ($type) {
            case 1: // 底部导航
                $data = app(NaviBottom::class)->getFetchInfo($id);
                break;

            default:
                # code...
                break;
        }

        return $data;
    }

    /**
     * 协议内容
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-06-11
     */
    public function content($type, $id)
    {
        $data = new ArrayObject();
        // 查询
        switch ($type) {
            case 1: // 底部导航
                $data->title   = app(NaviBottom::class)->getTitle($id);
                $data->content = app(NaviBottom::class)->getContent($id);
                break;

            default:
                # code...
                break;
        }

        return $data;
    }
}
